<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>My Project: libs/defs.h 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">My Project
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'搜索','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_6719ab1f1f7655efc2fa43f7eb574fd1.html">libs</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">defs.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="defs_8h.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#ifndef __LIBS_DEFS_H__</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#define __LIBS_DEFS_H__</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160; </div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#ifndef NULL</span></div>
<div class="line"><a name="l00005"></a><span class="lineno"><a class="line" href="defs_8h.html#a070d2ce7b6bb7e5c05602aa8c308d0c4">    5</a></span>&#160;<span class="preprocessor">#define NULL ((void *)0)</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160; </div>
<div class="line"><a name="l00008"></a><span class="lineno"><a class="line" href="defs_8h.html#a6034e8cd4bcd5bacfd060abd01bbd8a8">    8</a></span>&#160;<span class="preprocessor">#define __always_inline inline __attribute__((always_inline))</span></div>
<div class="line"><a name="l00009"></a><span class="lineno"><a class="line" href="defs_8h.html#a2a3055fa9fd2b7c91df69c75e185e76f">    9</a></span>&#160;<span class="preprocessor">#define __noinline __attribute__((noinline))</span></div>
<div class="line"><a name="l00010"></a><span class="lineno"><a class="line" href="defs_8h.html#a5b6df4fe38493e14648842364a76075f">   10</a></span>&#160;<span class="preprocessor">#define __noreturn __attribute__((noreturn))</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160; </div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment">/* Represents true-or-false values */</span></div>
<div class="line"><a name="l00013"></a><span class="lineno"><a class="line" href="defs_8h.html#a1062901a7428fdd9c7f180f5e01ea056">   13</a></span>&#160;<span class="keyword">typedef</span> <span class="keywordtype">int</span> <a class="code" href="defs_8h.html#a1062901a7428fdd9c7f180f5e01ea056">bool</a>;</div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160; </div>
<div class="line"><a name="l00015"></a><span class="lineno"><a class="line" href="defs_8h.html#a41f9c5fb8b08eb5dc3edce4dcb37fee7">   15</a></span>&#160;<span class="preprocessor">#define true (1)</span></div>
<div class="line"><a name="l00016"></a><span class="lineno"><a class="line" href="defs_8h.html#a65e9886d74aaee76545e83dd09011727">   16</a></span>&#160;<span class="preprocessor">#define false (0)</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160; </div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="comment">/* Explicitly-sized versions of integer types */</span></div>
<div class="line"><a name="l00019"></a><span class="lineno"><a class="line" href="defs_8h.html#ad566f6541e98b74246db1a3a3a85ad49">   19</a></span>&#160;<span class="keyword">typedef</span> <span class="keywordtype">char</span> <a class="code" href="defs_8h.html#ad566f6541e98b74246db1a3a3a85ad49">int8_t</a>;</div>
<div class="line"><a name="l00020"></a><span class="lineno"><a class="line" href="defs_8h.html#aba7bc1797add20fe3efdf37ced1182c5">   20</a></span>&#160;<span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> <a class="code" href="defs_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a>;</div>
<div class="line"><a name="l00021"></a><span class="lineno"><a class="line" href="defs_8h.html#aa343fa3b3d06292b959ffdd4c4703b06">   21</a></span>&#160;<span class="keyword">typedef</span> <span class="keywordtype">short</span> <a class="code" href="defs_8h.html#aa343fa3b3d06292b959ffdd4c4703b06">int16_t</a>;</div>
<div class="line"><a name="l00022"></a><span class="lineno"><a class="line" href="defs_8h.html#a273cf69d639a59973b6019625df33e30">   22</a></span>&#160;<span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> <a class="code" href="defs_8h.html#a273cf69d639a59973b6019625df33e30">uint16_t</a>;</div>
<div class="line"><a name="l00023"></a><span class="lineno"><a class="line" href="defs_8h.html#a32f2e37ee053cf2ce8ca28d1f74630e5">   23</a></span>&#160;<span class="keyword">typedef</span> <span class="keywordtype">int</span> <a class="code" href="defs_8h.html#a32f2e37ee053cf2ce8ca28d1f74630e5">int32_t</a>;</div>
<div class="line"><a name="l00024"></a><span class="lineno"><a class="line" href="defs_8h.html#a435d1572bf3f880d55459d9805097f62">   24</a></span>&#160;<span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="defs_8h.html#a435d1572bf3f880d55459d9805097f62">uint32_t</a>;</div>
<div class="line"><a name="l00025"></a><span class="lineno"><a class="line" href="defs_8h.html#a996e72f71b11a5bb8b3b7b6936b1516d">   25</a></span>&#160;<span class="keyword">typedef</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <a class="code" href="defs_8h.html#a996e72f71b11a5bb8b3b7b6936b1516d">int64_t</a>;</div>
<div class="line"><a name="l00026"></a><span class="lineno"><a class="line" href="defs_8h.html#aaa5d1cd013383c889537491c3cfd9aad">   26</a></span>&#160;<span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> <a class="code" href="defs_8h.html#aaa5d1cd013383c889537491c3cfd9aad">uint64_t</a>;</div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160; </div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="comment">/* *</span></div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="comment"> * Pointers and addresses are 32 bits or 64 bits.</span></div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160;<span class="comment"> * We use pointer types to represent addresses,</span></div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="comment"> * uintptr_t to represent the numerical values of addresses.</span></div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="comment"> * */</span></div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;<span class="preprocessor">#if __riscv_xlen == 64</span></div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;  <span class="keyword">typedef</span> <a class="code" href="defs_8h.html#a996e72f71b11a5bb8b3b7b6936b1516d">int64_t</a> sint_t;</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;  <span class="keyword">typedef</span> <a class="code" href="defs_8h.html#aaa5d1cd013383c889537491c3cfd9aad">uint64_t</a> uint_t;</div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;<span class="preprocessor">#elif __riscv_xlen == 32</span></div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;  <span class="keyword">typedef</span> <a class="code" href="defs_8h.html#a32f2e37ee053cf2ce8ca28d1f74630e5">int32_t</a> sint_t;</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;  <span class="keyword">typedef</span> <a class="code" href="defs_8h.html#a435d1572bf3f880d55459d9805097f62">uint32_t</a> uint_t;</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;<span class="preprocessor">#endif</span></div>
<div class="line"><a name="l00040"></a><span class="lineno"><a class="line" href="defs_8h.html#ad1c3e7815414ef1752c829f69ffbb6cd">   40</a></span>&#160;<span class="keyword">typedef</span> sint_t <a class="code" href="defs_8h.html#ad1c3e7815414ef1752c829f69ffbb6cd">intptr_t</a>;</div>
<div class="line"><a name="l00041"></a><span class="lineno"><a class="line" href="defs_8h.html#a04cf3633489292bdd23ff5b429bc476b">   41</a></span>&#160;<span class="keyword">typedef</span> uint_t <a class="code" href="defs_8h.html#a04cf3633489292bdd23ff5b429bc476b">uintptr_t</a>;</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160; </div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;<span class="comment">/* size_t is used for memory object sizes */</span></div>
<div class="line"><a name="l00044"></a><span class="lineno"><a class="line" href="defs_8h.html#afeaa5ef46acd844422607ca6602691ef">   44</a></span>&#160;<span class="keyword">typedef</span> <a class="code" href="defs_8h.html#a04cf3633489292bdd23ff5b429bc476b">uintptr_t</a> <a class="code" href="defs_8h.html#afeaa5ef46acd844422607ca6602691ef">size_t</a>;</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160; </div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;<span class="comment">/* used for page numbers */</span></div>
<div class="line"><a name="l00047"></a><span class="lineno"><a class="line" href="defs_8h.html#abafb6daca94570612947ad9188e76704">   47</a></span>&#160;<span class="keyword">typedef</span> <span class="keywordtype">size_t</span> <a class="code" href="defs_8h.html#abafb6daca94570612947ad9188e76704">ppn_t</a>;</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160; </div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;<span class="comment">/* *</span></div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;<span class="comment"> * Rounding operations (efficient when n is a power of 2)</span></div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;<span class="comment"> * Round down to the nearest multiple of n</span></div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;<span class="comment"> * */</span></div>
<div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="defs_8h.html#a057810d35075597ca699719778344515">   53</a></span>&#160;<span class="preprocessor">#define ROUNDDOWN(a, n) ({                                          \</span></div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;<span class="preprocessor">            size_t __a = (size_t)(a);                               \</span></div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;<span class="preprocessor">            (typeof(a))(__a - __a % (n));                           \</span></div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;<span class="preprocessor">        })</span></div>
<div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160; </div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;<span class="comment">/* Round up to the nearest multiple of n */</span></div>
<div class="line"><a name="l00059"></a><span class="lineno"><a class="line" href="defs_8h.html#a5d25fbed833545ed7a3c01e818de0bcf">   59</a></span>&#160;<span class="preprocessor">#define ROUNDUP(a, n) ({                                            \</span></div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;<span class="preprocessor">            size_t __n = (size_t)(n);                               \</span></div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;<span class="preprocessor">            (typeof(a))(ROUNDDOWN((size_t)(a) + __n - 1, __n));     \</span></div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;<span class="preprocessor">        })</span></div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160; </div>
<div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;<span class="comment">/* Return the offset of &#39;member&#39; relative to the beginning of a struct type */</span></div>
<div class="line"><a name="l00065"></a><span class="lineno"><a class="line" href="defs_8h.html#afd049f7ad59dbe455f460807475c2841">   65</a></span>&#160;<span class="preprocessor">#define offsetof(type, member)                                      \</span></div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;<span class="preprocessor">    ((size_t)(&amp;((type *)0)-&gt;member))</span></div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160; </div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;<span class="comment">/* *</span></div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;<span class="comment"> * to_struct - get the struct from a ptr</span></div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;<span class="comment"> * @ptr:    a struct pointer of member</span></div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;<span class="comment"> * @type:   the type of the struct this is embedded in</span></div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;<span class="comment"> * @member: the name of the member within the struct</span></div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;<span class="comment"> * */</span></div>
<div class="line"><a name="l00074"></a><span class="lineno"><a class="line" href="defs_8h.html#a9319e8a2aa1ca109db93ec14f04524e1">   74</a></span>&#160;<span class="preprocessor">#define to_struct(ptr, type, member)                               \</span></div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;<span class="preprocessor">    ((type *)((char *)(ptr) - offsetof(type, member)))</span></div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160; </div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;<span class="preprocessor">#endif </span><span class="comment">/* !__LIBS_DEFS_H__ */</span><span class="preprocessor"></span></div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160; </div>
<div class="ttc" id="adefs_8h_html_a04cf3633489292bdd23ff5b429bc476b"><div class="ttname"><a href="defs_8h.html#a04cf3633489292bdd23ff5b429bc476b">uintptr_t</a></div><div class="ttdeci">uint_t uintptr_t</div><div class="ttdef"><b>Definition:</b> defs.h:41</div></div>
<div class="ttc" id="adefs_8h_html_a1062901a7428fdd9c7f180f5e01ea056"><div class="ttname"><a href="defs_8h.html#a1062901a7428fdd9c7f180f5e01ea056">bool</a></div><div class="ttdeci">int bool</div><div class="ttdef"><b>Definition:</b> defs.h:13</div></div>
<div class="ttc" id="adefs_8h_html_a273cf69d639a59973b6019625df33e30"><div class="ttname"><a href="defs_8h.html#a273cf69d639a59973b6019625df33e30">uint16_t</a></div><div class="ttdeci">unsigned short uint16_t</div><div class="ttdef"><b>Definition:</b> defs.h:22</div></div>
<div class="ttc" id="adefs_8h_html_a32f2e37ee053cf2ce8ca28d1f74630e5"><div class="ttname"><a href="defs_8h.html#a32f2e37ee053cf2ce8ca28d1f74630e5">int32_t</a></div><div class="ttdeci">int int32_t</div><div class="ttdef"><b>Definition:</b> defs.h:23</div></div>
<div class="ttc" id="adefs_8h_html_a435d1572bf3f880d55459d9805097f62"><div class="ttname"><a href="defs_8h.html#a435d1572bf3f880d55459d9805097f62">uint32_t</a></div><div class="ttdeci">unsigned int uint32_t</div><div class="ttdef"><b>Definition:</b> defs.h:24</div></div>
<div class="ttc" id="adefs_8h_html_a996e72f71b11a5bb8b3b7b6936b1516d"><div class="ttname"><a href="defs_8h.html#a996e72f71b11a5bb8b3b7b6936b1516d">int64_t</a></div><div class="ttdeci">long long int64_t</div><div class="ttdef"><b>Definition:</b> defs.h:25</div></div>
<div class="ttc" id="adefs_8h_html_aa343fa3b3d06292b959ffdd4c4703b06"><div class="ttname"><a href="defs_8h.html#aa343fa3b3d06292b959ffdd4c4703b06">int16_t</a></div><div class="ttdeci">short int16_t</div><div class="ttdef"><b>Definition:</b> defs.h:21</div></div>
<div class="ttc" id="adefs_8h_html_aaa5d1cd013383c889537491c3cfd9aad"><div class="ttname"><a href="defs_8h.html#aaa5d1cd013383c889537491c3cfd9aad">uint64_t</a></div><div class="ttdeci">unsigned long long uint64_t</div><div class="ttdef"><b>Definition:</b> defs.h:26</div></div>
<div class="ttc" id="adefs_8h_html_aba7bc1797add20fe3efdf37ced1182c5"><div class="ttname"><a href="defs_8h.html#aba7bc1797add20fe3efdf37ced1182c5">uint8_t</a></div><div class="ttdeci">unsigned char uint8_t</div><div class="ttdef"><b>Definition:</b> defs.h:20</div></div>
<div class="ttc" id="adefs_8h_html_abafb6daca94570612947ad9188e76704"><div class="ttname"><a href="defs_8h.html#abafb6daca94570612947ad9188e76704">ppn_t</a></div><div class="ttdeci">size_t ppn_t</div><div class="ttdef"><b>Definition:</b> defs.h:47</div></div>
<div class="ttc" id="adefs_8h_html_ad1c3e7815414ef1752c829f69ffbb6cd"><div class="ttname"><a href="defs_8h.html#ad1c3e7815414ef1752c829f69ffbb6cd">intptr_t</a></div><div class="ttdeci">sint_t intptr_t</div><div class="ttdef"><b>Definition:</b> defs.h:40</div></div>
<div class="ttc" id="adefs_8h_html_ad566f6541e98b74246db1a3a3a85ad49"><div class="ttname"><a href="defs_8h.html#ad566f6541e98b74246db1a3a3a85ad49">int8_t</a></div><div class="ttdeci">char int8_t</div><div class="ttdef"><b>Definition:</b> defs.h:19</div></div>
<div class="ttc" id="adefs_8h_html_afeaa5ef46acd844422607ca6602691ef"><div class="ttname"><a href="defs_8h.html#afeaa5ef46acd844422607ca6602691ef">size_t</a></div><div class="ttdeci">uintptr_t size_t</div><div class="ttdef"><b>Definition:</b> defs.h:44</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1
</small></address>
</body>
</html>
